package cn.ddz;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class PokerGame {
    static List<String> list = new ArrayList<>();
    //静态代码块
    //特点：随着类的加载而在加载的，而且只执行一次。
    static {
        //准备牌
        // "♦", "♣", "♥", "♠"
        // "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"
        String[] color = {"♦", "♣", "♥", "♠"};
        String[] numbers = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        for (String c : color) {
            for (String n : numbers) {
                list.add(c+n);
            }
        }
        list.add("小王");
        list.add("大王");
    }
    public PokerGame(){
        Collections.shuffle(list);
        //发牌
        List<String> lord = new ArrayList<>();
        List<String> player1 = new ArrayList<>();
        List<String> player2 = new ArrayList<>();
        List<String> player3 = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if (i<=2){
                lord.add(list.get(i));
                continue;
            }
            if (i%3==0){
                player1.add(list.get(i));
            }else if (i%3==1){
                player2.add(list.get(i));
            }else {
                player3.add(list.get(i));
            }
        }
        lookPoker("底牌",lord);
        lookPoker("吊毛1",player1);
        lookPoker("吊毛2",player2);
        lookPoker("吊毛3",player3);
    }

    /*
     * 参数一：玩家的名字
     * 参数二：每位玩家的牌
     * */
    public void lookPoker(String name, List<String> list){
        System.out.print(name + ": ");
        for (String poker : list) {
            System.out.print(poker + " ");
        }
        System.out.println();
    }
}
